

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>AtomsList and AtomsReader objects for I/O &mdash; quippy 7ea04c5+ documentation</title>
  

  
  
    <link rel="shortcut icon" href="_static/favicon.ico"/>
  
  
  

  
  <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script type="text/javascript" src="_static/jquery.js"></script>
        <script type="text/javascript" src="_static/underscore.js"></script>
        <script type="text/javascript" src="_static/doctools.js"></script>
        <script type="text/javascript" src="_static/language_data.js"></script>
        <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
        <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"processClass": "math|output_area", "processEscapes": true, "ignoreClass": "document", "inlineMath": [["$", "$"], ["\\(", "\\)"]]}})</script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="_static/theme_overrides.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="index.html" class="icon icon-home"> quippy
          

          
            
            <img src="_static/hybrid.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
              <div class="version">
                7ea04c5+
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
    
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="intro.html">Introduction to <code class="docutils literal notranslate"><span class="pre">quippy</span></code></a></li>
<li class="toctree-l1"><a class="reference internal" href="install.html">Installation of QUIP and quippy</a></li>
<li class="toctree-l1"><a class="reference internal" href="Tutorials/index.html">Tutorials</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="quippy.html">Quippy library reference</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="quippy.html#core-functionality">Core functionality</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="atoms.html">Atoms objects</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">AtomsList and AtomsReader objects for I/O</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#supported-file-formats">Supported File Formats</a></li>
<li class="toctree-l4"><a class="reference internal" href="#module-ase.io.extxyz">Extended XYZ</a></li>
<li class="toctree-l4"><a class="reference internal" href="#netcdf">NetCDF</a></li>
<li class="toctree-l4"><a class="reference internal" href="#module-quippy.cinoutput">CInOutput objects</a></li>
<li class="toctree-l4"><a class="reference internal" href="#module-quippy.asap">ASAP file format</a></li>
<li class="toctree-l4"><a class="reference internal" href="#module-quippy.atomeyewriter">AtomEye Image Writer</a></li>
<li class="toctree-l4"><a class="reference internal" href="#castep">CASTEP</a></li>
<li class="toctree-l4"><a class="reference internal" href="#module-quippy.cube">Gaussian CUBE</a></li>
<li class="toctree-l4"><a class="reference internal" href="#module-quippy.dan">DAN visualisation code</a></li>
<li class="toctree-l4"><a class="reference internal" href="#module-quippy.imd">IMD checkpoint</a></li>
<li class="toctree-l4"><a class="reference internal" href="#nmwiz-plugin-for-vmd">NMWiz plugin for VMD</a></li>
<li class="toctree-l4"><a class="reference internal" href="#module-quippy.povray">POV-ray</a></li>
<li class="toctree-l4"><a class="reference internal" href="#vasp">VASP</a></li>
<li class="toctree-l4"><a class="reference internal" href="#ase-supported-files-types">ASE supported files types</a></li>
<li class="toctree-l4"><a class="reference internal" href="#adding-a-new-file-type">Adding a new file type</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="potential.html">Potential objects</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="quippy.html#structure-generation-manipulation-and-analysis">Structure generation, manipulation and analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="quippy.html#molecular-dynamics">Molecular Dynamics</a></li>
<li class="toctree-l2"><a class="reference internal" href="quippy.html#additional-tools-for-potentials">Additional tools for Potentials</a></li>
<li class="toctree-l2"><a class="reference internal" href="quippy.html#mathematical-and-optimisation-tools">Mathematical and optimisation tools</a></li>
<li class="toctree-l2"><a class="reference internal" href="quippy.html#units-data-and-constants">Units, Data and Constants</a></li>
<li class="toctree-l2"><a class="reference internal" href="quippy.html#low-level-routines-and-datatypes">Low level routines and datatypes</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="visualisation.html">Visualisation Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="fortran_wrapper.html">Appendix: wrapping Fortran 90 Code</a></li>
<li class="toctree-l1"><a class="reference internal" href="teach_sparse.html">Command line options of the teach_sparse main program</a></li>
</ul>

            
          
    <p></p>
    <ul>
        <li><a href="genindex.html">Index</a></li>
        <li><a href="py-modindex.html">Module Index</a></li>
        <li><a href="search.html">Search Page</a></li>
        <li><a href="_modules/index.html">Module Source Code</a></li>
    </ul>
  
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">quippy</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html">Docs</a> &raquo;</li>
        
          <li><a href="quippy.html">Quippy library reference</a> &raquo;</li>
        
      <li>AtomsList and AtomsReader objects for I/O</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/io.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  
<style>
/* CSS overrides for sphinx_rtd_theme */

/* 24px margin */
.nbinput.nblast,
.nboutput.nblast {
    margin-bottom: 19px;  /* padding has already 5px */
}

/* ... except between code cells! */
.nblast + .nbinput {
    margin-top: -19px;
}

.admonition > p:before {
    margin-right: 4px;  /* make room for the exclamation icon */
}

/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */
.math {
    text-align: unset;
}
</style>
<div class="section" id="module-quippy.io">
<span id="atomslist-and-atomsreader-objects-for-i-o"></span><h1>AtomsList and AtomsReader objects for I/O<a class="headerlink" href="#module-quippy.io" title="Permalink to this headline">¶</a></h1>
<p>There are two classes for reading trajectories: <a class="reference internal" href="#quippy.io.AtomsReader" title="quippy.io.AtomsReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsReader</span></code></a>
and <a class="reference internal" href="#quippy.io.AtomsList" title="quippy.io.AtomsList"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsList</span></code></a>. Use an <a class="reference internal" href="#quippy.io.AtomsReader" title="quippy.io.AtomsReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsReader</span></code></a> for quick
read-only access to a trajectory or if you only want to access some of
the frames. If you want to load the entire file into memory and
manipulate it use an <a class="reference internal" href="#quippy.io.AtomsList" title="quippy.io.AtomsList"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsList</span></code></a>.</p>
<p>Module contents for <a class="reference internal" href="#module-quippy.io" title="quippy.io: Read and write atomic configurations"><code class="xref py py-mod docutils literal notranslate"><span class="pre">quippy.io</span></code></a>:</p>
<p class="rubric">Classes</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#quippy.io.AtomsReader" title="quippy.io.AtomsReader"><code class="xref py py-obj docutils literal notranslate"><span class="pre">AtomsReader</span></code></a>(source[,&nbsp;format,&nbsp;start,&nbsp;stop,&nbsp;…])</td>
<td>An <a class="reference internal" href="#quippy.io.AtomsReader" title="quippy.io.AtomsReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsReader</span></code></a> reads a series of <code class="xref py py-class docutils literal notranslate"><span class="pre">Atoms</span></code> objects from the trajectory <cite>source</cite> which should be one of the following:</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.io.AtomsList" title="quippy.io.AtomsList"><code class="xref py py-obj docutils literal notranslate"><span class="pre">AtomsList</span></code></a>([source,&nbsp;format,&nbsp;start,&nbsp;stop,&nbsp;…])</td>
<td>An <a class="reference internal" href="#quippy.io.AtomsList" title="quippy.io.AtomsList"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsList</span></code></a> is just like an <a class="reference internal" href="#quippy.io.AtomsReader" title="quippy.io.AtomsReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsReader</span></code></a> except that all frames are read in on initialiased and then stored in memory.</td>
</tr>
</tbody>
</table>
<p class="rubric">Functions</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#quippy.io.atoms_reader" title="quippy.io.atoms_reader"><code class="xref py py-obj docutils literal notranslate"><span class="pre">atoms_reader</span></code></a>(source)</td>
<td>Decorator to mark a function as a reader for a particular file extension</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.io.AtomsWriter" title="quippy.io.AtomsWriter"><code class="xref py py-obj docutils literal notranslate"><span class="pre">AtomsWriter</span></code></a>(dest[,&nbsp;format])</td>
<td>Returns a file-like object for writing Atoms to <cite>dest</cite> which should be either a filename or an initiliased output object.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#quippy.io.read_dataset" title="quippy.io.read_dataset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">read_dataset</span></code></a>(dirs,&nbsp;pattern,&nbsp;**kwargs)</td>
<td>Read atomic configurations matching glob <cite>pattern</cite> from each of the directories in <cite>dir</cite> in turn.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.io.time_ordered_series" title="quippy.io.time_ordered_series"><code class="xref py py-obj docutils literal notranslate"><span class="pre">time_ordered_series</span></code></a>(source[,&nbsp;dt])</td>
<td>Given a source of Atoms configurations, return a time ordered list of filename and frame references</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#quippy.io.read" title="quippy.io.read"><code class="xref py py-obj docutils literal notranslate"><span class="pre">read</span></code></a>(filename,&nbsp;**readargs)</td>
<td>Read Atoms from file <cite>filename</cite></td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.io.write" title="quippy.io.write"><code class="xref py py-obj docutils literal notranslate"><span class="pre">write</span></code></a>(filename,&nbsp;atoms,&nbsp;**writeargs)</td>
<td>Write <cite>atoms</cite> to the file <cite>filename</cite></td>
</tr>
</tbody>
</table>
<p class="rubric">Attributes</p>
<table border="1" class="docutils">
<colgroup>
<col width="80%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Name</th>
<th class="head">Value</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><a class="reference internal" href="#quippy.io.AtomsReaders" title="quippy.io.AtomsReaders"><code class="xref py py-attr docutils literal notranslate"><span class="pre">AtomsReaders</span></code></a></td>
<td>—</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#quippy.io.AtomsWriters" title="quippy.io.AtomsWriters"><code class="xref py py-attr docutils literal notranslate"><span class="pre">AtomsWriters</span></code></a></td>
<td>—</td>
</tr>
</tbody>
</table>
<dl class="class">
<dt id="quippy.io.AtomsReader">
<em class="property">class </em><code class="descclassname">quippy.io.</code><code class="descname">AtomsReader</code><span class="sig-paren">(</span><em>source</em>, <em>format=None</em>, <em>start=None</em>, <em>stop=None</em>, <em>step=None</em>, <em>cache_mem_limit=-1</em>, <em>rename=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/io.html#AtomsReader"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.io.AtomsReader" title="Permalink to this definition">¶</a></dt>
<dd><p>An <a class="reference internal" href="#quippy.io.AtomsReader" title="quippy.io.AtomsReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsReader</span></code></a> reads a series of <code class="xref py py-class docutils literal notranslate"><span class="pre">Atoms</span></code> objects
from the trajectory <cite>source</cite> which should be one of the following:</p>
<blockquote>
<div><ul class="simple">
<li>a filename - in this case <cite>format</cite> is inferred from the file
extension – see <a class="reference internal" href="#fileformats"><span class="std std-ref">Supported File Formats</span></a></li>
<li>a shell-style glob pattern e.g. <cite>“*.xyz”</cite></li>
<li>a list of filenames or glob patterns e.g. <cite>[“foo*.xyz”,
“bar*.xyz”]</cite></li>
<li>an open file or file-like object (e.g. a <code class="xref py py-class docutils literal notranslate"><span class="pre">CInOutput</span></code>
object)</li>
<li>any Python <a class="reference external" href="http://docs.python.org/library/stdtypes.html#iterator-types">iterator</a>
which yields a sequence of <code class="xref py py-class docutils literal notranslate"><span class="pre">Atoms</span></code> objects</li>
</ul>
</div></blockquote>
<p><cite>start</cite>, <cite>stop</cite> and <cite>step</cite> can be used to restrict the range of frames
read from <cite>source</cite>. The first frame in the file has index zero.</p>
<p><cite>cache_limit</cite> determines how many configurations will be stored in
memory. If more than <cite>cache_limit</cite> configurations are read in, the
least recently accessed configurations are thrown away. To store
everything, use an <a class="reference internal" href="#quippy.io.AtomsList" title="quippy.io.AtomsList"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsList</span></code></a> instead.</p>
<p>Some <cite>sources</cite> understand additional keyword arguments from
<cite>**kwargs</cite>. For example the CASTEP file reader can take an
<cite>atoms_ref</cite> argument which is a reference <code class="xref py py-class docutils literal notranslate"><span class="pre">Atoms</span></code> object
which is used to fill in information which is missing from the
input file.</p>
<p>All <a class="reference internal" href="#quippy.io.AtomsReaders" title="quippy.io.AtomsReaders"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsReaders</span></code></a> support iteration, so you can loop over
the contents using a <a class="reference external" href="https://docs.python.org/2.7/reference/compound_stmts.html#for" title="(in Python v2.7)"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">for</span></code></a> loop:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">al</span> <span class="o">=</span> <span class="n">AtomsReader</span><span class="p">(</span><span class="s1">&#39;input-file.xyz&#39;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">at</span> <span class="ow">in</span> <span class="n">al</span><span class="p">:</span>
   <span class="c1"># process Atoms object `at`</span>
   <span class="nb">print</span> <span class="n">at</span><span class="o">.</span><span class="n">energy</span>
</pre></div>
</div>
<p>or using list comprehension:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="p">[</span><span class="n">at</span><span class="o">.</span><span class="n">energy</span> <span class="k">for</span> <span class="n">at</span> <span class="ow">in</span> <span class="n">al</span><span class="p">]</span>
</pre></div>
</div>
<p>In addition to iteration, some sources allow random access. To find
out if an <a class="reference internal" href="#quippy.io.AtomsReader" title="quippy.io.AtomsReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsReader</span></code></a> supports random access, either try
to get it’s length with <a class="reference external" href="https://docs.python.org/2.7/library/functions.html#len" title="(in Python v2.7)"><code class="xref py py-func docutils literal notranslate"><span class="pre">len()</span></code></a>, or check if the
<a class="reference internal" href="#quippy.io.AtomsReader.random_access" title="quippy.io.AtomsReader.random_access"><code class="xref py py-attr docutils literal notranslate"><span class="pre">random_access</span></code></a> property is true. If <cite>cache_limit</cite> is large
enough to store all the frames in the file, all
<a class="reference internal" href="#quippy.io.AtomsReaders" title="quippy.io.AtomsReaders"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsReaders</span></code></a> will allow random access once the entire
trajectory has been loaded.</p>
<p>If <code class="xref py py-attr docutils literal notranslate"><span class="pre">randomaccess</span></code> is true, you can access individual frames
by indexing and slicing, e.g. <code class="docutils literal notranslate"><span class="pre">al[i]</span></code> is the i<sup>th</sup>
<code class="xref py py-class docutils literal notranslate"><span class="pre">Atoms</span></code> object within <code class="docutils literal notranslate"><span class="pre">al</span></code> and <code class="docutils literal notranslate"><span class="pre">al[i:j]</span></code> returns objects
from <cite>i</cite> upto but not including <cite>j</cite>. Like ordinary Python lists,
indices start from 0 and run up to <code class="docutils literal notranslate"><span class="pre">len(al)-1</span></code>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Attributes:</th><td class="field-body"><dl class="first last docutils">
<dt><a class="reference internal" href="#quippy.io.AtomsReader.random_access" title="quippy.io.AtomsReader.random_access"><code class="xref py py-obj docutils literal notranslate"><span class="pre">random_access</span></code></a></dt>
<dd><p class="first last">Read only property: True if this source supports random access, False if it does not</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Methods</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#quippy.io.AtomsReader.close" title="quippy.io.AtomsReader.close"><code class="xref py py-obj docutils literal notranslate"><span class="pre">close</span></code></a>()</td>
<td>Close any open files associated with this <a class="reference internal" href="#quippy.io.AtomsReader" title="quippy.io.AtomsReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsReader</span></code></a></td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.io.AtomsReader.filter" title="quippy.io.AtomsReader.filter"><code class="xref py py-obj docutils literal notranslate"><span class="pre">filter</span></code></a>(at)</td>
<td>Apply read-time filters to <cite>at</cite></td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#quippy.io.AtomsReader.iterframes" title="quippy.io.AtomsReader.iterframes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">iterframes</span></code></a>([reverse])</td>
<td>Return an interator over all the frames in this trajectory.</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="quippy.io.AtomsReader.close">
<code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/io.html#AtomsReader.close"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.io.AtomsReader.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Close any open files associated with this <a class="reference internal" href="#quippy.io.AtomsReader" title="quippy.io.AtomsReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsReader</span></code></a></p>
</dd></dl>

<dl class="method">
<dt id="quippy.io.AtomsReader.filter">
<code class="descname">filter</code><span class="sig-paren">(</span><em>at</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/io.html#AtomsReader.filter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.io.AtomsReader.filter" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply read-time filters to <cite>at</cite></p>
</dd></dl>

<dl class="method">
<dt id="quippy.io.AtomsReader.iterframes">
<code class="descname">iterframes</code><span class="sig-paren">(</span><em>reverse=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/io.html#AtomsReader.iterframes"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.io.AtomsReader.iterframes" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an interator over all the frames in this trajectory. This
is the default iterator for an <a class="reference internal" href="#quippy.io.AtomsReader" title="quippy.io.AtomsReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsReader</span></code></a> instance
<cite>al</cite>, and can be accessed with <code class="docutils literal notranslate"><span class="pre">iter(al)</span></code>.</p>
<p>If <cite>reverse=True</cite> then the iteration starts with the last frame
and goes backwards through the file. This is only possible if
<a class="reference internal" href="#quippy.io.AtomsReader.random_access" title="quippy.io.AtomsReader.random_access"><code class="xref py py-attr docutils literal notranslate"><span class="pre">random_access</span></code></a> is true.</p>
</dd></dl>

<dl class="attribute">
<dt id="quippy.io.AtomsReader.random_access">
<code class="descname">random_access</code><a class="headerlink" href="#quippy.io.AtomsReader.random_access" title="Permalink to this definition">¶</a></dt>
<dd><p>Read only property: True if this source supports random access, False if it does not</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="quippy.io.AtomsList">
<em class="property">class </em><code class="descclassname">quippy.io.</code><code class="descname">AtomsList</code><span class="sig-paren">(</span><em>source=[]</em>, <em>format=None</em>, <em>start=None</em>, <em>stop=None</em>, <em>step=None</em>, <em>rename=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/io.html#AtomsList"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.io.AtomsList" title="Permalink to this definition">¶</a></dt>
<dd><p>An <a class="reference internal" href="#quippy.io.AtomsList" title="quippy.io.AtomsList"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsList</span></code></a> is just like an <a class="reference internal" href="#quippy.io.AtomsReader" title="quippy.io.AtomsReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsReader</span></code></a> except
that all frames are read in on initialiased and then stored in
memory. This is equivalent to an <a class="reference internal" href="#quippy.io.AtomsReader" title="quippy.io.AtomsReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsReader</span></code></a> with a
<cite>cache_limit</cite> of <cite>None</cite> so an <a class="reference internal" href="#quippy.io.AtomsList" title="quippy.io.AtomsList"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsList</span></code></a> always
supports random access.</p>
<p>The <a class="reference internal" href="#quippy.io.AtomsList" title="quippy.io.AtomsList"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsList</span></code></a> allows configurations to be added, removed
or reordered using the standard Python methods for <a class="reference external" href="http://docs.python.org/library/stdtypes.html#mutable-sequence-types">mutable
sequence types</a>
(e.g. <code class="xref py py-meth docutils literal notranslate"><span class="pre">append()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">extend()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">index()</span></code>, etc).</p>
<p>The attributes of the component <code class="xref py py-class docutils literal notranslate"><span class="pre">Atoms</span></code> can be accessed as a
single array, using the frame number as the first array index. Note
that the first index runs from 0 to <cite>len(al)-1</cite>, unlike the other
indices which are one-based since the <code class="xref py py-class docutils literal notranslate"><span class="pre">Atoms</span></code> attributes are
stored in a <code class="xref py py-class docutils literal notranslate"><span class="pre">FortranArray</span></code>.</p>
<p>For example the following statements are all true:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">al</span><span class="o">.</span><span class="n">energy</span>      <span class="o">==</span>  <span class="p">[</span><span class="n">at</span><span class="o">.</span><span class="n">energy</span> <span class="k">for</span> <span class="n">at</span> <span class="ow">in</span> <span class="n">al</span><span class="p">]</span> <span class="c1"># energies of all atoms</span>
<span class="n">al</span><span class="o">.</span><span class="n">energy</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>   <span class="o">==</span>  <span class="n">al</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">energy</span>             <span class="c1"># energy of first frame</span>
<span class="nb">all</span><span class="p">(</span><span class="n">al</span><span class="o">.</span><span class="n">velo</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span>  <span class="n">al</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">velo</span><span class="p">)</span>              <span class="c1"># velocities of all atoms in first frame</span>
<span class="n">al</span><span class="o">.</span><span class="n">velo</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>  <span class="o">==</span>  <span class="n">al</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">velo</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>           <span class="c1"># velocity of last atom in first frame</span>
</pre></div>
</div>
<p>In addition to the standard Python list methods and those of
<a class="reference internal" href="#quippy.io.AtomsReader" title="quippy.io.AtomsReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsReader</span></code></a>, <a class="reference internal" href="#quippy.io.AtomsList" title="quippy.io.AtomsList"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsList</span></code></a> defined a couple of extras
methods.</p>
<dl class="method">
<dt id="quippy.io.AtomsList.sort">
<code class="descname">sort</code><span class="sig-paren">(</span><em>cmp=None</em>, <em>key=None</em>, <em>reverse=False</em>, <em>attr=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/io.html#AtomsList.sort"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.io.AtomsList.sort" title="Permalink to this definition">¶</a></dt>
<dd><p>Sort the AtomsList in place. This is the same as the standard
<code class="xref py py-meth docutils literal notranslate"><span class="pre">list.sort()</span></code> method, except for the additional <cite>attr</cite>
argument. If this is present then the sorted list will be
ordered by the <code class="xref py py-class docutils literal notranslate"><span class="pre">Atoms</span></code> attribute <cite>attr</cite>, e.g.:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">al</span><span class="o">.</span><span class="n">sort</span><span class="p">(</span><span class="n">attr</span><span class="o">=</span><span class="s1">&#39;energy&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>will order the configurations by their <cite>energy</cite> (assuming that
<code class="xref py py-attr docutils literal notranslate"><span class="pre">Atoms.params</span></code> contains an entry named <cite>energy</cite> for each
configuration; otherwise an <code class="xref py py-exc docutils literal notranslate"><span class="pre">AttributError</span></code> will be raised).</p>
</dd></dl>

</dd></dl>

<dl class="function">
<dt id="quippy.io.atoms_reader">
<code class="descclassname">quippy.io.</code><code class="descname">atoms_reader</code><span class="sig-paren">(</span><em>source</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/io.html#atoms_reader"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.io.atoms_reader" title="Permalink to this definition">¶</a></dt>
<dd><p>Decorator to mark a function as a reader for a particular file extension</p>
</dd></dl>

<dl class="function">
<dt id="quippy.io.AtomsWriter">
<code class="descclassname">quippy.io.</code><code class="descname">AtomsWriter</code><span class="sig-paren">(</span><em>dest</em>, <em>format=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/io.html#AtomsWriter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.io.AtomsWriter" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a file-like object for writing Atoms to <cite>dest</cite> which
should be either a filename or an initiliased output object.  If
<cite>format</cite> is not given it is inferred from the file extension of
<cite>dest</cite>. Example usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">out</span> <span class="o">=</span> <span class="n">AtomsWriter</span><span class="p">(</span><span class="s1">&#39;out_file.xyz&#39;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">at</span> <span class="ow">in</span> <span class="n">seq</span><span class="p">:</span>
   <span class="n">out</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">at</span><span class="p">)</span>
<span class="n">out</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="quippy.io.read_dataset">
<code class="descclassname">quippy.io.</code><code class="descname">read_dataset</code><span class="sig-paren">(</span><em>dirs</em>, <em>pattern</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/io.html#read_dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.io.read_dataset" title="Permalink to this definition">¶</a></dt>
<dd><p>Read atomic configurations matching glob <cite>pattern</cite> from each of
the directories in <cite>dir</cite> in turn. All kwargs are passed along
to AtomsList constructor.</p>
<p>Returns an dictionary mapping directories to AtomsList instances.</p>
</dd></dl>

<dl class="function">
<dt id="quippy.io.time_ordered_series">
<code class="descclassname">quippy.io.</code><code class="descname">time_ordered_series</code><span class="sig-paren">(</span><em>source</em>, <em>dt=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/io.html#time_ordered_series"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.io.time_ordered_series" title="Permalink to this definition">¶</a></dt>
<dd><p>Given a source of Atoms configurations, return a time ordered list of filename and frame references</p>
</dd></dl>

<dl class="function">
<dt id="quippy.io.read">
<code class="descclassname">quippy.io.</code><code class="descname">read</code><span class="sig-paren">(</span><em>filename</em>, <em>**readargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/io.html#read"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.io.read" title="Permalink to this definition">¶</a></dt>
<dd><p>Read Atoms from file <cite>filename</cite></p>
<p>File format is inferred from file extension, see <a class="reference internal" href="#fileformats"><span class="std std-ref">Supported File Formats</span></a>.</p>
</dd></dl>

<dl class="function">
<dt id="quippy.io.write">
<code class="descclassname">quippy.io.</code><code class="descname">write</code><span class="sig-paren">(</span><em>filename</em>, <em>atoms</em>, <em>**writeargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/io.html#write"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.io.write" title="Permalink to this definition">¶</a></dt>
<dd><p>Write <cite>atoms</cite> to the file <cite>filename</cite></p>
<p>File format is inferred from file extension, see <a class="reference internal" href="#fileformats"><span class="std std-ref">Supported File Formats</span></a>.</p>
</dd></dl>

<div class="section" id="supported-file-formats">
<span id="fileformats"></span><h2>Supported File Formats<a class="headerlink" href="#supported-file-formats" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference internal" href="#quippy.io.AtomsReaders" title="quippy.io.AtomsReaders"><code class="xref py py-attr docutils literal notranslate"><span class="pre">AtomsReaders</span></code></a> and <a class="reference internal" href="#quippy.io.AtomsWriters" title="quippy.io.AtomsWriters"><code class="xref py py-attr docutils literal notranslate"><span class="pre">AtomsWriters</span></code></a> dictionaries are
used by the <code class="xref py py-class docutils literal notranslate"><span class="pre">Atoms</span></code> constructor, <code class="xref py py-meth docutils literal notranslate"><span class="pre">Atoms.write()</span></code>, the
<a class="reference internal" href="#quippy.io.AtomsList" title="quippy.io.AtomsList"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsList</span></code></a> constructor and <code class="xref py py-meth docutils literal notranslate"><span class="pre">AtomsList.write()</span></code> to work out
how to read or write a particular file type, based on the filename
extension.</p>
<p>The quippy native formats are <a class="reference internal" href="#extendedxyz"><span class="std std-ref">Extended XYZ</span></a> and <a class="reference internal" href="#netcdf"><span class="std std-ref">NetCDF</span></a>.</p>
<p>The standard implementation of both these formats is in C in the files
<code class="file docutils literal notranslate"><span class="pre">xyz.c</span></code> and <code class="file docutils literal notranslate"><span class="pre">netcdf.c</span></code> in the <cite>libAtoms</cite> package. It is
this version which is wrapped by the
<a class="reference internal" href="#quippy.cinoutput.CInOutput" title="quippy.cinoutput.CInOutput"><code class="xref py py-class docutils literal notranslate"><span class="pre">CInOutput</span></code></a> class, which is used by
<a class="reference internal" href="#quippy.io.AtomsReader" title="quippy.io.AtomsReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsReader</span></code></a> and <a class="reference internal" href="#quippy.io.AtomsList" title="quippy.io.AtomsList"><code class="xref py py-class docutils literal notranslate"><span class="pre">AtomsList</span></code></a> when
reading from or writing to XYZ or NetCDF files.</p>
<dl class="attribute">
<dt id="quippy.io.AtomsReaders">
<code class="descclassname">quippy.io.</code><code class="descname">AtomsReaders</code><a class="headerlink" href="#quippy.io.AtomsReaders" title="Permalink to this definition">¶</a></dt>
<dd><p>Supported file formats for reading <a class="reference internal" href="atoms.html#quippy.atoms.Atoms" title="quippy.atoms.Atoms"><code class="xref py py-class docutils literal notranslate"><span class="pre">Atoms</span></code></a> objects from files.</p>
<table border="1" class="docutils">
<colgroup>
<col width="37%" />
<col width="63%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">File extension</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">castep</span></code> or
<code class="docutils literal notranslate"><span class="pre">castep_log</span></code></td>
<td><a class="reference internal" href="#castep"><span class="std std-ref">CASTEP</span></a> output</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">cell</span></code></td>
<td><a class="reference internal" href="#castep"><span class="std std-ref">CASTEP</span></a> cell files</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">chkpt</span></code></td>
<td><a class="reference internal" href="#imd"><span class="std std-ref">IMD checkpoint</span></a></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">cp2k_output</span></code></td>
<td><a class="reference internal" href="cp2k.html#cp2k"><span class="std std-ref">CP2K I/O and driver</span></a></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">cube</span></code></td>
<td><a class="reference internal" href="#cube"><span class="std std-ref">Gaussian CUBE</span></a></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">geom</span></code></td>
<td><a class="reference internal" href="#castep"><span class="std std-ref">CASTEP</span></a> geometry</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">md</span></code></td>
<td><a class="reference internal" href="#castep"><span class="std std-ref">CASTEP</span></a> MD file</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">nc</span></code></td>
<td><a class="reference internal" href="#netcdf"><span class="std std-ref">NetCDF</span></a></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">pos</span></code></td>
<td><a class="reference internal" href="#asap"><span class="std std-ref">ASAP file format</span></a></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">POSCAR</span></code> or
<code class="docutils literal notranslate"><span class="pre">CONTCAR</span></code>,</td>
<td><a class="reference internal" href="#vasp"><span class="std std-ref">VASP</span></a> coordinates</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">OUTCAR</span></code>,</td>
<td><a class="reference internal" href="#vasp"><span class="std std-ref">VASP</span></a> output</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">stdin</span></code></td>
<td>Read from stdin in
<a class="reference internal" href="#extendedxyz"><span class="std std-ref">Extended XYZ</span></a> format</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">string</span></code></td>
<td>Read from string in
<a class="reference internal" href="#extendedxyz"><span class="std std-ref">Extended XYZ</span></a> format</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">xyz</span></code></td>
<td><a class="reference internal" href="#extendedxyz"><span class="std std-ref">Extended XYZ</span></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="quippy.io.AtomsWriters">
<code class="descclassname">quippy.io.</code><code class="descname">AtomsWriters</code><a class="headerlink" href="#quippy.io.AtomsWriters" title="Permalink to this definition">¶</a></dt>
<dd><p>Supported file formats for writing <a class="reference internal" href="atoms.html#quippy.atoms.Atoms" title="quippy.atoms.Atoms"><code class="xref py py-class docutils literal notranslate"><span class="pre">Atoms</span></code></a> objects to files.</p>
<table border="1" class="docutils">
<colgroup>
<col width="36%" />
<col width="64%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">File extension</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">cell</span></code></td>
<td><a class="reference internal" href="#castep"><span class="std std-ref">CASTEP</span></a> cell file</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">cube</span></code></td>
<td><a class="reference internal" href="#cube"><span class="std std-ref">Gaussian CUBE</span></a></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">dan</span></code></td>
<td><a class="reference internal" href="#dan"><span class="std std-ref">DAN visualisation code</span></a></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">eps</span></code>,
<code class="docutils literal notranslate"><span class="pre">jpg</span></code>,
<code class="docutils literal notranslate"><span class="pre">png</span></code>,</td>
<td>Images
(via:ref:<cite>atomeyewriter</cite>)</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">nc</span></code></td>
<td><a class="reference internal" href="#netcdf"><span class="std std-ref">NetCDF</span></a></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">nmd</span></code></td>
<td><span class="xref std std-ref">nmwiz</span></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">pos</span></code></td>
<td><a class="reference internal" href="#asap"><span class="std std-ref">ASAP file format</span></a></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">pov</span></code></td>
<td><a class="reference internal" href="#povray"><span class="std std-ref">POV-ray</span></a></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">POSCAR</span></code></td>
<td><a class="reference internal" href="#vasp"><span class="std std-ref">VASP</span></a> coordinates</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">-</span></code>,
<code class="docutils literal notranslate"><span class="pre">stdout</span></code></td>
<td>Write to stdout in
<a class="reference internal" href="#extendedxyz"><span class="std std-ref">Extended XYZ</span></a> format</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">string</span></code></td>
<td>Write to string in
<a class="reference internal" href="#extendedxyz"><span class="std std-ref">Extended XYZ</span></a> format</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">xyz</span></code></td>
<td><a class="reference internal" href="#extendedxyz"><span class="std std-ref">Extended XYZ</span></a></td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
<div class="section" id="module-ase.io.extxyz">
<span id="extended-xyz"></span><span id="extendedxyz"></span><h2>Extended XYZ<a class="headerlink" href="#module-ase.io.extxyz" title="Permalink to this headline">¶</a></h2>
<p>Extended XYZ format is an enhanced version of the <a class="reference external" href="http://en.wikipedia.org/wiki/XYZ_file_format">basic XYZ format</a> that allows extra
columns to be present in the file for additonal per-atom properties as
well as standardising the format of the comment line to include the
cell lattice and other per-frame parameters.</p>
<p>It’s easiest to describe the format with an example.  Here is a
standard XYZ file containing a bulk cubic 8 atom silicon cell</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">8</span>
<span class="n">Cubic</span> <span class="n">bulk</span> <span class="n">silicon</span> <span class="n">cell</span>
<span class="n">Si</span>        <span class="mf">0.00000000</span>      <span class="mf">0.00000000</span>      <span class="mf">0.00000000</span>
<span class="n">Si</span>        <span class="mf">1.36000000</span>      <span class="mf">1.36000000</span>      <span class="mf">1.36000000</span>
<span class="n">Si</span>        <span class="mf">2.72000000</span>      <span class="mf">2.72000000</span>      <span class="mf">0.00000000</span>
<span class="n">Si</span>        <span class="mf">4.08000000</span>      <span class="mf">4.08000000</span>      <span class="mf">1.36000000</span>
<span class="n">Si</span>        <span class="mf">2.72000000</span>      <span class="mf">0.00000000</span>      <span class="mf">2.72000000</span>
<span class="n">Si</span>        <span class="mf">4.08000000</span>      <span class="mf">1.36000000</span>      <span class="mf">4.08000000</span>
<span class="n">Si</span>        <span class="mf">0.00000000</span>      <span class="mf">2.72000000</span>      <span class="mf">2.72000000</span>
<span class="n">Si</span>        <span class="mf">1.36000000</span>      <span class="mf">4.08000000</span>      <span class="mf">4.08000000</span>
</pre></div>
</div>
<p>The first line is the number of atoms, followed by a comment and
then one line per atom, giving the element symbol and cartesian
x y, and z coordinates in Angstroms.</p>
<p>Here’s the same configuration in extended XYZ format</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">8</span>
<span class="n">Lattice</span><span class="o">=</span><span class="s2">&quot;5.44 0.0 0.0 0.0 5.44 0.0 0.0 0.0 5.44&quot;</span> <span class="n">Properties</span><span class="o">=</span><span class="n">species</span><span class="p">:</span><span class="n">S</span><span class="p">:</span><span class="mi">1</span><span class="p">:</span><span class="n">pos</span><span class="p">:</span><span class="n">R</span><span class="p">:</span><span class="mi">3</span> <span class="n">Time</span><span class="o">=</span><span class="mf">0.0</span>
<span class="n">Si</span>        <span class="mf">0.00000000</span>      <span class="mf">0.00000000</span>      <span class="mf">0.00000000</span>
<span class="n">Si</span>        <span class="mf">1.36000000</span>      <span class="mf">1.36000000</span>      <span class="mf">1.36000000</span>
<span class="n">Si</span>        <span class="mf">2.72000000</span>      <span class="mf">2.72000000</span>      <span class="mf">0.00000000</span>
<span class="n">Si</span>        <span class="mf">4.08000000</span>      <span class="mf">4.08000000</span>      <span class="mf">1.36000000</span>
<span class="n">Si</span>        <span class="mf">2.72000000</span>      <span class="mf">0.00000000</span>      <span class="mf">2.72000000</span>
<span class="n">Si</span>        <span class="mf">4.08000000</span>      <span class="mf">1.36000000</span>      <span class="mf">4.08000000</span>
<span class="n">Si</span>        <span class="mf">0.00000000</span>      <span class="mf">2.72000000</span>      <span class="mf">2.72000000</span>
<span class="n">Si</span>        <span class="mf">1.36000000</span>      <span class="mf">4.08000000</span>      <span class="mf">4.08000000</span>
</pre></div>
</div>
<p>In extended XYZ format, the comment line is replaced by a series of
key/value pairs.  The keys should be strings and values can be
integers, reals, logicals (denoted by <cite>T</cite> and <cite>F</cite> for true and false)
or strings. Quotes are required if a value contains any spaces (like
<cite>Lattice</cite> above).  There are two mandatory parameters that any
extended XYZ: <cite>Lattice</cite> and <cite>Properties</cite>. Other parameters –
e.g. <cite>Time</cite> in the example above — can be added to the parameter line
as needed.</p>
<p><cite>Lattice</cite> is a Cartesian 3x3 matrix representation of the cell
<a class="reference internal" href="atoms.html#quippy.atoms.Atoms.lattice" title="quippy.atoms.Atoms.lattice"><code class="xref py py-attr docutils literal notranslate"><span class="pre">lattice</span></code></a> vectors, with each vector stored
as a column and the 9 values listed in Fortran column-major order, i.e. in
the form</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Lattice</span><span class="o">=</span><span class="s2">&quot;R1x R1y R1z R2x R2y R2z R3x R3y R3z&quot;</span>
</pre></div>
</div>
<p>where <cite>R1x R1y R1z</cite> are the Cartesian x-, y- and z-components of the
first lattice vector (<span class="math notranslate nohighlight">\(\mathbf{a}\)</span>), <cite>R2x R2y R2z</cite> those of the second
lattice vector (<span class="math notranslate nohighlight">\(\mathbf{b}\)</span>) and <cite>R3x R3y R3z</cite> those of the
third lattice vector (<span class="math notranslate nohighlight">\(\mathbf{c}\)</span>).</p>
<p>The list of properties in the file is described by the <cite>Properties</cite>
parameter, which should take the form of a series of colon separated
triplets giving the name, format (<cite>R</cite> for real, <cite>I</cite> for integer) and
number of columns of each property. For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Properties</span><span class="o">=</span><span class="s2">&quot;species:S:1:pos:R:3:vel:R:3:select:I:1&quot;</span>
</pre></div>
</div>
<p>indicates the first column represents atomic species, the next three
columns represent atomic positions, the next three velcoities, and the
last is an single integer called <cite>select</cite>. With this property
definition, the line</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Si</span>        <span class="mf">4.08000000</span>      <span class="mf">4.08000000</span>      <span class="mf">1.36000000</span>   <span class="mf">0.00000000</span>      <span class="mf">0.00000000</span>      <span class="mf">0.00000000</span>       <span class="mi">1</span>
</pre></div>
</div>
<p>would describe a silicon atom at position (4.08,4.08,1.36) with zero
velocity and the <cite>select</cite> property set to 1.</p>
<p>The extended XYZ format is now also supported by the
<a class="reference external" href="https://wiki.fysik.dtu.dk/ase/ase/io/io.html#ase.io.read" title="(in ASE)"><code class="xref py py-func docutils literal notranslate"><span class="pre">ase.io.read()</span></code></a> and <a class="reference external" href="https://wiki.fysik.dtu.dk/ase/ase/io/io.html#ase.io.write" title="(in ASE)"><code class="xref py py-func docutils literal notranslate"><span class="pre">ase.io.write()</span></code></a> functions in the <a class="reference external" href="https://wiki.fysik.dtu.dk/ase">Atomic
Simulation Environment (ASE)</a>
toolkit, and by the <a class="reference external" href="http://www.ovito.org">Ovito</a> visualisation tool
(from <a class="reference external" href="http://www.ovito.org/index.php/component/content/article?id=25">v2.4 beta</a>
onwards).</p>
</div>
<div class="section" id="netcdf">
<span id="id1"></span><h2>NetCDF<a class="headerlink" href="#netcdf" title="Permalink to this headline">¶</a></h2>
<span class="target" id="module-quippy.netcdf"></span><p>We use the <a class="reference external" href="http://www.unidata.ucar.edu/software/netcdf/">NetCDF file format</a>, a flexible binary
file format designed for scientific array data.</p>
<p>We use a superset of the <a class="reference external" href="http://amber.scripps.edu/netcdf/nctraj.html">AMBER conventions</a>, so that our
trajectory file can be read directly by VMD. An important distinction
from the Extended XYZ format is the names of some properties:</p>
<table border="1" class="docutils">
<colgroup>
<col width="49%" />
<col width="51%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Extended XYZ name</th>
<th class="head">NetCDF name</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>pos</td>
<td>coordinates</td>
</tr>
<tr class="row-odd"><td>velo</td>
<td>velocities</td>
</tr>
</tbody>
</table>
<p>This mapping is handled automatically by, but if you access the data
directly you’ll need to be aware of it.</p>
<p>NetCDF versions 3 and 4 are supported. If version 4 is used then it’s
possible to use zlib compression, which greatly reduces the file size.</p>
<div class="section" id="netcdf-convention">
<h3>NetCDF Convention<a class="headerlink" href="#netcdf-convention" title="Permalink to this headline">¶</a></h3>
<p>All data is either per-atom (referred to as a <cite>property</cite>) or per-frame (refereed to as a <cite>parameter</cite>).</p>
</div>
<div class="section" id="dimensions">
<h3>Dimensions<a class="headerlink" href="#dimensions" title="Permalink to this headline">¶</a></h3>
<blockquote>
<div><ul class="simple">
<li><cite>frame</cite> - number of frames (this is the unlimited dimension)</li>
<li><cite>spatial</cite> - number of spatial dimensions (i.e. 3)</li>
<li><cite>atom</cite> - number of atoms</li>
<li><cite>cell_spatial</cite> - number of cell lengths (i.e. 3)</li>
<li><cite>cell_angular</cite> - number of cell angles (i.e. 3)</li>
<li><cite>label</cite> - length of string properies (per-atom character data, e.g. species, value is 10)</li>
<li><cite>string</cite> - length of string parameters (per-frame string data, value is 1024)</li>
</ul>
</div></blockquote>
</div>
<div class="section" id="variables">
<h3>Variables<a class="headerlink" href="#variables" title="Permalink to this headline">¶</a></h3>
<p>Global variables</p>
<blockquote>
<div><ul class="simple">
<li><cite>spatial (spatial)</cite> - character, equal to <cite>(‘x’,’y’,’z’)</cite></li>
<li><cite>cell_spatial (cell_spatial)</cite> - character, equal to <cite>(‘a’,’b’,’c’)</cite></li>
<li><cite>cell_angular (cell_angular, label)</cite> - character, equal to <cite>(‘alpha’, ‘beta’, ‘gamma’)</cite></li>
</ul>
</div></blockquote>
<p>Parameters (per-frame variables)</p>
<blockquote>
<div><ul class="simple">
<li><cite>cell_lengths (frame, cell_spatial)</cite> - double, cell lengths in Angstrom</li>
<li><cite>cell_angles (frame, cell_angular)</cite> - double, cell angles in degrees</li>
</ul>
</div></blockquote>
<p>Other parameters can be of type double, integer, logical or
string. Integer, logical and double types can be vectors or scalars
(i.e. dimension <cite>(frame)</cite> or <cite>(frame,spatial)</cite>), but string parameters
must be scalar (i.e. dimension <cite>(frame,string)</cite>. Additionally, real and
integer 3x3 matrices with dimension <cite>(frame,spatial,spatial)</cite> are
supported (e.g. for the virial tensor). In order to distinguish
between integer and logical variables, a special <cite>type</cite> attribute
should be added to the variable, set to one of the following values:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">T_INTEGER</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">T_REAL</span> <span class="o">=</span> <span class="mi">2</span>
<span class="n">T_LOGICAL</span> <span class="o">=</span> <span class="mi">4</span>
<span class="n">T_INTEGER_A</span> <span class="o">=</span> <span class="mi">5</span>
<span class="n">T_REAL_A</span> <span class="o">=</span> <span class="mi">6</span>
<span class="n">T_LOGICAL_A</span> <span class="o">=</span> <span class="mi">8</span>
<span class="n">T_CHAR</span> <span class="o">=</span> <span class="mi">9</span>
<span class="n">T_INTEGER_A2</span> <span class="o">=</span> <span class="mi">12</span>
<span class="n">T_REAL_A2</span> <span class="o">=</span> <span class="mi">13</span>
</pre></div>
</div>
<p>Properties (per-atom variables)</p>
<p>Properties can be of type integer, real, string or logical. As for parameters,
integer, real and logical properties can be scalar
(dimension <cite>(frame,atom)</cite>) or vector (dimension <cite>(frame,atom,spatial)</cite>), but
string properties must be of dimension <cite>(frame,atom,label)</cite>. Again a <cite>type</cite>
attribute must be added to the NetCDF variable, with one of the following values:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">PROPERTY_INT</span>     <span class="o">=</span> <span class="mi">1</span>
<span class="n">PROPERTY_REAL</span>    <span class="o">=</span> <span class="mi">2</span>
<span class="n">PROPERTY_STR</span>     <span class="o">=</span> <span class="mi">3</span>
<span class="n">PROPERTY_LOGICAL</span> <span class="o">=</span> <span class="mi">4</span>
</pre></div>
</div>
<p>See the <a class="reference internal" href="#module-quippy.netcdf" title="quippy.netcdf: Python reference implementation of NetCDF I/O"><code class="xref py py-mod docutils literal notranslate"><span class="pre">quippy.netcdf</span></code></a> module for a reference implementation of the
NetCDF reading and writing routines, in pure Python.</p>
</div>
</div>
<div class="section" id="module-quippy.cinoutput">
<span id="cinoutput-objects"></span><h2>CInOutput objects<a class="headerlink" href="#module-quippy.cinoutput" title="Permalink to this headline">¶</a></h2>
<p>Module contents for <a class="reference internal" href="#module-quippy.cinoutput" title="quippy.cinoutput: XYZ and NetCDF I/O using fast C routines"><code class="xref py py-mod docutils literal notranslate"><span class="pre">quippy.cinoutput</span></code></a>:</p>
<p class="rubric">Classes</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#quippy.cinoutput.CInOutputReader" title="quippy.cinoutput.CInOutputReader"><code class="xref py py-obj docutils literal notranslate"><span class="pre">CInOutputReader</span></code></a>(source[,&nbsp;frame,&nbsp;range,&nbsp;…])</td>
<td>Class to read atoms from a CInOutput.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.cinoutput.CInOutputWriter" title="quippy.cinoutput.CInOutputWriter"><code class="xref py py-obj docutils literal notranslate"><span class="pre">CInOutputWriter</span></code></a>(dest[,&nbsp;append,&nbsp;netcdf4,&nbsp;…])</td>
<td>Class to write atoms sequentially to a CInOutput stream</td>
</tr>
</tbody>
</table>
<p class="rubric">Functions</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#quippy.cinoutput.quip_md5sum" title="quippy.cinoutput.quip_md5sum"><code class="xref py py-obj docutils literal notranslate"><span class="pre">quip_md5sum</span></code></a>(filename,[stat])</td>
<td><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.cinoutput.quip_getcwd" title="quippy.cinoutput.quip_getcwd"><code class="xref py py-obj docutils literal notranslate"><span class="pre">quip_getcwd</span></code></a>()</td>
<td><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#quippy.cinoutput.quip_dirname" title="quippy.cinoutput.quip_dirname"><code class="xref py py-obj docutils literal notranslate"><span class="pre">quip_dirname</span></code></a>(*args,&nbsp;**kwargs)</td>
<td>Routine is wrapper around Fortran interface <code class="docutils literal notranslate"><span class="pre">quip_dirname</span></code> containing multiple routines:</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.cinoutput.quip_chdir" title="quippy.cinoutput.quip_chdir"><code class="xref py py-obj docutils literal notranslate"><span class="pre">quip_chdir</span></code></a>(*args,&nbsp;**kwargs)</td>
<td>Routine is wrapper around Fortran interface <code class="docutils literal notranslate"><span class="pre">quip_chdir</span></code> containing multiple routines:</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#quippy.cinoutput.quip_basename" title="quippy.cinoutput.quip_basename"><code class="xref py py-obj docutils literal notranslate"><span class="pre">quip_basename</span></code></a>(*args,&nbsp;**kwargs)</td>
<td>Routine is wrapper around Fortran interface <code class="docutils literal notranslate"><span class="pre">quip_basename</span></code> containing multiple routines:</td>
</tr>
</tbody>
</table>
<p class="rubric">Attributes</p>
<table border="1" class="docutils">
<colgroup>
<col width="81%" />
<col width="19%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Name</th>
<th class="head">Value</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="xref py py-attr docutils literal notranslate"><span class="pre">NETCDF_FORMAT</span></code></td>
<td>2</td>
</tr>
<tr class="row-odd"><td><code class="xref py py-attr docutils literal notranslate"><span class="pre">LATTICE_TOL</span></code></td>
<td>1e-08</td>
</tr>
<tr class="row-even"><td><code class="xref py py-attr docutils literal notranslate"><span class="pre">XYZ_FORMAT</span></code></td>
<td>1</td>
</tr>
</tbody>
</table>
<dl class="class">
<dt id="quippy.cinoutput.CInOutput">
<em class="property">class </em><code class="descclassname">quippy.cinoutput.</code><code class="descname">CInOutput</code><span class="sig-paren">(</span><em>filename=None</em>, <em>action=0</em>, <em>append=False</em>, <em>netcdf4=False</em>, <em>no_compute_index=None</em>, <em>frame=None</em>, <em>one_frame_per_file=None</em>, <em>mpi=None</em>, <em>zero=False</em>, <em>range=None</em>, <em>indices=None</em>, <em>fpointer=None</em>, <em>finalise=True</em>, <em>string=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/cinoutput.html#CInOutput"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.cinoutput.CInOutput" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">quippy._cinoutput.CInOutput</span></code></p>
<p class="rubric">Methods</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#quippy.cinoutput.CInOutput.close" title="quippy.cinoutput.CInOutput.close"><code class="xref py py-obj docutils literal notranslate"><span class="pre">close</span></code></a>(*args,&nbsp;**kwargs)</td>
<td>cinoutput_close</td>
</tr>
<tr class="row-even"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">is_same_fortran_object</span></code>(other)</td>
<td>Test if <cite>self</cite> and <cite>other</cite> point to the same Fortan object.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#quippy.cinoutput.CInOutput.read" title="quippy.cinoutput.CInOutput.read"><code class="xref py py-obj docutils literal notranslate"><span class="pre">read</span></code></a>(…)</td>
<td>Read an Atoms object from this CInOutput stream.</td>
</tr>
<tr class="row-even"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">shallow_copy</span></code>()</td>
<td>Return a shallow copy of <cite>self</cite>.</td>
</tr>
<tr class="row-odd"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">shallow_copy_from</span></code>(other)</td>
<td>Transform <cite>self</cite> into a shallow copy of <cite>other</cite>.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.cinoutput.CInOutput.write" title="quippy.cinoutput.CInOutput.write"><code class="xref py py-obj docutils literal notranslate"><span class="pre">write</span></code></a>(…)</td>
<td>Write an Atoms object to this CInOutput stream.</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="quippy.cinoutput.CInOutput.close">
<code class="descname">close</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#quippy.cinoutput.CInOutput.close" title="Permalink to this definition">¶</a></dt>
<dd><p>cinoutput_close</p>
<p>Close file. After a call to close(), you can can call initialise() again
to reopen a new file.</p>
<p class="rubric">References</p>
<p>Routine is wrapper around Fortran routine <code class="docutils literal notranslate"><span class="pre">close</span></code> defined in file <a class="reference external" href="https://github.com/libAtoms/QUIP/blob/public/src/libAtoms/CInOutput.f95">src/libAtoms/CInOutput.f95</a>.</p>
</dd></dl>

<dl class="method">
<dt id="quippy.cinoutput.CInOutput.read">
<code class="descname">read</code><span class="sig-paren">(</span><em>at</em><span class="optional">[</span>, <em>properties</em>, <em>properties_array</em>, <em>frame</em>, <em>zero</em>, <em>range</em>, <em>str</em>, <em>estr</em>, <em>indices</em>, <em>error</em><span class="optional">]</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/cinoutput.html#CInOutput.read"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.cinoutput.CInOutput.read" title="Permalink to this definition">¶</a></dt>
<dd><p>Read an Atoms object from this CInOutput stream.</p>
<p>Important <a class="reference internal" href="atoms.html#quippy.atoms.Atoms.properties" title="quippy.atoms.Atoms.properties"><code class="xref py py-attr docutils literal notranslate"><span class="pre">properties</span></code></a> which may be present (non-exhaustive list):</p>
<ul class="simple">
<li><strong>species</strong>, str, 1 col – atomic species, e.g. Si or H</li>
<li><strong>pos</strong>, real, 3 cols – cartesian positions, in A</li>
<li><strong>Z</strong>, int, 1 col – atomic numbers</li>
<li><strong>mass</strong>, real, 1 col – atomic masses, in A,eV,fs units system</li>
<li><strong>velo</strong>, real, 3 cols – velocities, in A/fs</li>
<li><strong>acc</strong>, real, 3 cols – accelerations, in A/fs:math:<cite>^2</cite></li>
<li><strong>hybrid</strong>, int, 1 col – one for QM atoms and zero for hybrid atoms</li>
<li><strong>frac_pos</strong>, real, 3 cols – fractional positions of atoms</li>
</ul>
<p>Along with all <code class="xref py py-attr docutils literal notranslate"><span class="pre">params</span></code> entries, the
<a class="reference internal" href="atoms.html#quippy.atoms.Atoms.lattice" title="quippy.atoms.Atoms.lattice"><code class="xref py py-attr docutils literal notranslate"><span class="pre">lattice</span></code></a>, <a class="reference internal" href="atoms.html#quippy.atoms.Atoms.cutoff" title="quippy.atoms.Atoms.cutoff"><code class="xref py py-attr docutils literal notranslate"><span class="pre">cutoff</span></code></a>, and
attr:<cite>~Atoms.nneightol</cite> attributes are read from the comment
line of XYZ file, or from special variables in NetCDF files</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><dl class="first last docutils">
<dt><strong>at</strong> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="atoms.html#quippy.atoms.Atoms" title="quippy.atoms.Atoms"><code class="xref py py-class docutils literal notranslate"><span class="pre">Atoms</span></code></a> object</span></dt>
<dd></dd>
<dt><strong>properties</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input string(len=-1), optional</span></dt>
<dd></dd>
<dt><strong>properties_array</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input rank-2 array(‘S’) with bounds (qp_n0,(*)), optional</span></dt>
<dd></dd>
<dt><strong>frame</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input int, optional</span></dt>
<dd></dd>
<dt><strong>zero</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input int, optional</span></dt>
<dd></dd>
<dt><strong>range</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input rank-1 array(‘i’) with bounds (2), optional</span></dt>
<dd></dd>
<dt><strong>str</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input string(len=-1), optional</span></dt>
<dd></dd>
<dt><strong>estr</strong> <span class="classifier-delimiter">:</span> <span class="classifier"><code class="xref py py-class docutils literal notranslate"><span class="pre">Extendable_str</span></code> object, optional</span></dt>
<dd></dd>
<dt><strong>indices</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input rank-1 array(‘i’) with bounds (qp_n1), optional</span></dt>
<dd></dd>
<dt><strong>error</strong> <span class="classifier-delimiter">:</span> <span class="classifier">in/output rank-0 array(int,’i’), optional</span></dt>
<dd></dd>
</dl>
</td>
</tr>
</tbody>
</table>
<p class="rubric">References</p>
<p>Routine is wrapper around Fortran routine <code class="docutils literal notranslate"><span class="pre">read</span></code> defined in file <a class="reference external" href="https://github.com/libAtoms/QUIP/blob/public/src/libAtoms/CInOutput.f95">src/libAtoms/CInOutput.f95</a>.</p>
</dd></dl>

<dl class="method">
<dt id="quippy.cinoutput.CInOutput.write">
<code class="descname">write</code><span class="sig-paren">(</span><em>at</em><span class="optional">[</span>, <em>properties</em>, <em>properties_array</em>, <em>prefix</em>, <em>int_format</em>, <em>real_format</em>, <em>frame</em>, <em>shuffle</em>, <em>deflate</em>, <em>deflate_level</em>, <em>estr</em>, <em>update_index</em>, <em>error</em><span class="optional">]</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/cinoutput.html#CInOutput.write"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.cinoutput.CInOutput.write" title="Permalink to this definition">¶</a></dt>
<dd><p>Write an Atoms object to this CInOutput stream.
Along with all atomic <a class="reference internal" href="atoms.html#quippy.atoms.Atoms.properties" title="quippy.atoms.Atoms.properties"><code class="xref py py-attr docutils literal notranslate"><span class="pre">properties</span></code></a> and
<code class="xref py py-attr docutils literal notranslate"><span class="pre">params</span></code> entries, the <a class="reference internal" href="atoms.html#quippy.atoms.Atoms.lattice" title="quippy.atoms.Atoms.lattice"><code class="xref py py-attr docutils literal notranslate"><span class="pre">lattice</span></code></a>,
<a class="reference internal" href="atoms.html#quippy.atoms.Atoms.cutoff" title="quippy.atoms.Atoms.cutoff"><code class="xref py py-attr docutils literal notranslate"><span class="pre">cutoff</span></code></a> and attr:<cite>~Atoms.nneightol</cite> attributes
are written to the comment line of XYZ file, or from special
variables in NetCDF files</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><dl class="first last docutils">
<dt><strong>at</strong> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="atoms.html#quippy.atoms.Atoms" title="quippy.atoms.Atoms"><code class="xref py py-class docutils literal notranslate"><span class="pre">Atoms</span></code></a> object</span></dt>
<dd></dd>
<dt><strong>properties</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input string(len=-1), optional</span></dt>
<dd></dd>
<dt><strong>properties_array</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input rank-2 array(‘S’) with bounds (qp_n0,(*)), optional</span></dt>
<dd></dd>
<dt><strong>prefix</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input string(len=-1), optional</span></dt>
<dd></dd>
<dt><strong>int_format</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input string(len=-1), optional</span></dt>
<dd></dd>
<dt><strong>real_format</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input string(len=-1), optional</span></dt>
<dd></dd>
<dt><strong>frame</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input int, optional</span></dt>
<dd></dd>
<dt><strong>shuffle</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input int, optional</span></dt>
<dd></dd>
<dt><strong>deflate</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input int, optional</span></dt>
<dd></dd>
<dt><strong>deflate_level</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input int, optional</span></dt>
<dd></dd>
<dt><strong>estr</strong> <span class="classifier-delimiter">:</span> <span class="classifier"><code class="xref py py-class docutils literal notranslate"><span class="pre">Extendable_str</span></code> object, optional</span></dt>
<dd></dd>
<dt><strong>update_index</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input int, optional</span></dt>
<dd></dd>
<dt><strong>error</strong> <span class="classifier-delimiter">:</span> <span class="classifier">in/output rank-0 array(int,’i’), optional</span></dt>
<dd></dd>
</dl>
</td>
</tr>
</tbody>
</table>
<p class="rubric">References</p>
<p>Routine is wrapper around Fortran routine <code class="docutils literal notranslate"><span class="pre">write</span></code> defined in file <a class="reference external" href="https://github.com/libAtoms/QUIP/blob/public/src/libAtoms/CInOutput.f95">src/libAtoms/CInOutput.f95</a>.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="quippy.cinoutput.CInOutputReader">
<em class="property">class </em><code class="descclassname">quippy.cinoutput.</code><code class="descname">CInOutputReader</code><span class="sig-paren">(</span><em>source</em>, <em>frame=None</em>, <em>range=None</em>, <em>start=0</em>, <em>stop=None</em>, <em>step=1</em>, <em>no_compute_index=False</em>, <em>zero=False</em>, <em>one_frame_per_file=False</em>, <em>indices=None</em>, <em>string=False</em>, <em>format=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/cinoutput.html#CInOutputReader"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.cinoutput.CInOutputReader" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/2.7/library/functions.html#object" title="(in Python v2.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></a></p>
<p>Class to read atoms from a CInOutput. Supports generator and random access via indexing.</p>
</dd></dl>

<dl class="class">
<dt id="quippy.cinoutput.CInOutputWriter">
<em class="property">class </em><code class="descclassname">quippy.cinoutput.</code><code class="descname">CInOutputWriter</code><span class="sig-paren">(</span><em>dest</em>, <em>append=False</em>, <em>netcdf4=False</em>, <em>one_frame_per_file=False</em>, <em>string=False</em>, <em>**write_kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/cinoutput.html#CInOutputWriter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.cinoutput.CInOutputWriter" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/2.7/library/functions.html#object" title="(in Python v2.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></a></p>
<p>Class to write atoms sequentially to a CInOutput stream</p>
</dd></dl>

<dl class="function">
<dt id="quippy.cinoutput.quip_md5sum">
<code class="descclassname">quippy.cinoutput.</code><code class="descname">quip_md5sum</code><span class="sig-paren">(</span><em>filename</em><span class="optional">[</span>, <em>stat</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#quippy.cinoutput.quip_md5sum" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><dl class="first docutils">
<dt><strong>filename</strong> <span class="classifier-delimiter">:</span> <span class="classifier">input string(len=-1)</span></dt>
<dd></dd>
<dt><strong>stat</strong> <span class="classifier-delimiter">:</span> <span class="classifier">in/output rank-0 array(int,’i’), optional</span></dt>
<dd></dd>
</dl>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><dl class="first last docutils">
<dt><strong>md5sum</strong> <span class="classifier-delimiter">:</span> <span class="classifier">string(len=32)</span></dt>
<dd></dd>
</dl>
</td>
</tr>
</tbody>
</table>
<p class="rubric">References</p>
<p>Routine is wrapper around Fortran routine <code class="docutils literal notranslate"><span class="pre">quip_md5sum</span></code> defined in file <a class="reference external" href="https://github.com/libAtoms/QUIP/blob/public/src/libAtoms/CInOutput.f95">src/libAtoms/CInOutput.f95</a>.</p>
</dd></dl>

<dl class="function">
<dt id="quippy.cinoutput.quip_getcwd">
<code class="descclassname">quippy.cinoutput.</code><code class="descname">quip_getcwd</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quippy.cinoutput.quip_getcwd" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><dl class="first last docutils">
<dt><strong>ret_quip_getcwd</strong> <span class="classifier-delimiter">:</span> <span class="classifier"><code class="xref py py-class docutils literal notranslate"><span class="pre">Extendable_str</span></code> object</span></dt>
<dd></dd>
</dl>
</td>
</tr>
</tbody>
</table>
<p class="rubric">References</p>
<p>Routine is wrapper around Fortran routine <code class="docutils literal notranslate"><span class="pre">quip_getcwd</span></code> defined in file <a class="reference external" href="https://github.com/libAtoms/QUIP/blob/public/src/libAtoms/CInOutput.f95">src/libAtoms/CInOutput.f95</a>.</p>
</dd></dl>

<dl class="function">
<dt id="quippy.cinoutput.quip_dirname">
<code class="descclassname">quippy.cinoutput.</code><code class="descname">quip_dirname</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#quippy.cinoutput.quip_dirname" title="Permalink to this definition">¶</a></dt>
<dd><p>Routine is wrapper around Fortran interface <code class="docutils literal notranslate"><span class="pre">quip_dirname</span></code> containing multiple routines:</p>
<blockquote>
<div><dl class="function">
<dt>
<code class="descclassname">quippy.cinoutput.</code><code class="descname">quip_dirname</code><span class="sig-paren">(</span><em>path</em><span class="sig-paren">)</span></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>path</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">Extendable_str</span></code> object) – </td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>ret_quip_dirname_extendable_str</strong> – <code class="xref py py-class docutils literal notranslate"><span class="pre">Extendable_str</span></code> object</td>
</tr>
</tbody>
</table>
<p>Routine is wrapper around Fortran routine <code class="docutils literal notranslate"><span class="pre">quip_dirname_extendable_str</span></code> defined in file <a class="reference external" href="https://github.com/libAtoms/QUIP/blob/public/src/libAtoms/CInOutput.f95">src/libAtoms/CInOutput.f95</a>.</p>
</dd></dl>

<dl class="function">
<dt>
<code class="descclassname">quippy.cinoutput.</code><code class="descname">quip_dirname</code><span class="sig-paren">(</span><em>path</em><span class="sig-paren">)</span></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>path</strong> (<em>input string</em><em>(</em><em>len=-1</em><em>)</em>) – </td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>ret_quip_dirname_char</strong> – <code class="xref py py-class docutils literal notranslate"><span class="pre">Extendable_str</span></code> object</td>
</tr>
</tbody>
</table>
<p>Routine is wrapper around Fortran routine <code class="docutils literal notranslate"><span class="pre">quip_dirname_char</span></code> defined in file <a class="reference external" href="https://github.com/libAtoms/QUIP/blob/public/src/libAtoms/CInOutput.f95">src/libAtoms/CInOutput.f95</a>.</p>
</dd></dl>

</div></blockquote>
</dd></dl>

<dl class="function">
<dt id="quippy.cinoutput.quip_chdir">
<code class="descclassname">quippy.cinoutput.</code><code class="descname">quip_chdir</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#quippy.cinoutput.quip_chdir" title="Permalink to this definition">¶</a></dt>
<dd><p>Routine is wrapper around Fortran interface <code class="docutils literal notranslate"><span class="pre">quip_chdir</span></code> containing multiple routines:</p>
<blockquote>
<div><dl class="function">
<dt>
<code class="descclassname">quippy.cinoutput.</code><code class="descname">quip_chdir</code><span class="sig-paren">(</span><em>path</em><span class="sig-paren">)</span></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>path</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">Extendable_str</span></code> object) – </td>
</tr>
</tbody>
</table>
<p>Routine is wrapper around Fortran routine <code class="docutils literal notranslate"><span class="pre">quip_chdir_extendable_str</span></code> defined in file <a class="reference external" href="https://github.com/libAtoms/QUIP/blob/public/src/libAtoms/CInOutput.f95">src/libAtoms/CInOutput.f95</a>.</p>
</dd></dl>

<dl class="function">
<dt>
<code class="descclassname">quippy.cinoutput.</code><code class="descname">quip_chdir</code><span class="sig-paren">(</span><em>path</em><span class="sig-paren">)</span></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>path</strong> (<em>input string</em><em>(</em><em>len=-1</em><em>)</em>) – </td>
</tr>
</tbody>
</table>
<p>Routine is wrapper around Fortran routine <code class="docutils literal notranslate"><span class="pre">quip_chdir_char</span></code> defined in file <a class="reference external" href="https://github.com/libAtoms/QUIP/blob/public/src/libAtoms/CInOutput.f95">src/libAtoms/CInOutput.f95</a>.</p>
</dd></dl>

</div></blockquote>
</dd></dl>

<dl class="function">
<dt id="quippy.cinoutput.quip_basename">
<code class="descclassname">quippy.cinoutput.</code><code class="descname">quip_basename</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#quippy.cinoutput.quip_basename" title="Permalink to this definition">¶</a></dt>
<dd><p>Routine is wrapper around Fortran interface <code class="docutils literal notranslate"><span class="pre">quip_basename</span></code> containing multiple routines:</p>
<blockquote>
<div><dl class="function">
<dt>
<code class="descclassname">quippy.cinoutput.</code><code class="descname">quip_basename</code><span class="sig-paren">(</span><em>path</em><span class="sig-paren">)</span></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>path</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">Extendable_str</span></code> object) – </td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>ret_quip_basename_extendable_str</strong> – <code class="xref py py-class docutils literal notranslate"><span class="pre">Extendable_str</span></code> object</td>
</tr>
</tbody>
</table>
<p>Routine is wrapper around Fortran routine <code class="docutils literal notranslate"><span class="pre">quip_basename_extendable_str</span></code> defined in file <a class="reference external" href="https://github.com/libAtoms/QUIP/blob/public/src/libAtoms/CInOutput.f95">src/libAtoms/CInOutput.f95</a>.</p>
</dd></dl>

<dl class="function">
<dt>
<code class="descclassname">quippy.cinoutput.</code><code class="descname">quip_basename</code><span class="sig-paren">(</span><em>path</em><span class="sig-paren">)</span></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>path</strong> (<em>input string</em><em>(</em><em>len=-1</em><em>)</em>) – </td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>ret_quip_basename_char</strong> – <code class="xref py py-class docutils literal notranslate"><span class="pre">Extendable_str</span></code> object</td>
</tr>
</tbody>
</table>
<p>Routine is wrapper around Fortran routine <code class="docutils literal notranslate"><span class="pre">quip_basename_char</span></code> defined in file <a class="reference external" href="https://github.com/libAtoms/QUIP/blob/public/src/libAtoms/CInOutput.f95">src/libAtoms/CInOutput.f95</a>.</p>
</dd></dl>

</div></blockquote>
</dd></dl>

</div>
<div class="section" id="module-quippy.asap">
<span id="asap-file-format"></span><span id="asap"></span><h2>ASAP file format<a class="headerlink" href="#module-quippy.asap" title="Permalink to this headline">¶</a></h2>
<p>This module contains utility functions for use with the ASAP code, which is developed
by Paul Tangney and Sandro Scandolo.</p>
<p>Module contents for <a class="reference internal" href="#module-quippy.asap" title="quippy.asap: ASAP file reader and writer"><code class="xref py py-mod docutils literal notranslate"><span class="pre">quippy.asap</span></code></a>:
..</p>
<blockquote>
<div>!! processed by numpydoc !!</div></blockquote>
</div>
<div class="section" id="module-quippy.atomeyewriter">
<span id="atomeye-image-writer"></span><span id="atomeyewriter"></span><h2>AtomEye Image Writer<a class="headerlink" href="#module-quippy.atomeyewriter" title="Permalink to this headline">¶</a></h2>
<p>Module contents for <a class="reference internal" href="#module-quippy.atomeyewriter" title="quippy.atomeyewriter: AtomEye image writer"><code class="xref py py-mod docutils literal notranslate"><span class="pre">quippy.atomeyewriter</span></code></a>:</p>
<p class="rubric">Classes</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#quippy.atomeyewriter.AtomEyeWriter" title="quippy.atomeyewriter.AtomEyeWriter"><code class="xref py py-obj docutils literal notranslate"><span class="pre">AtomEyeWriter</span></code></a>(image[,&nbsp;width,&nbsp;height,&nbsp;…])</td>
<td>Write atoms to image file (png/eps/jpg) using AtomEye</td>
</tr>
</tbody>
</table>
<dl class="class">
<dt id="quippy.atomeyewriter.AtomEyeWriter">
<em class="property">class </em><code class="descclassname">quippy.atomeyewriter.</code><code class="descname">AtomEyeWriter</code><span class="sig-paren">(</span><em>image</em>, <em>width=None</em>, <em>height=None</em>, <em>aspect=0.75</em>, <em>shift=True</em>, <em>commands=None</em>, <em>script=None</em>, <em>nowindow=True</em>, <em>number_frames=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/atomeyewriter.html#AtomEyeWriter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.atomeyewriter.AtomEyeWriter" title="Permalink to this definition">¶</a></dt>
<dd><p>Write atoms to image file (png/eps/jpg) using AtomEye</p>
</dd></dl>

</div>
<div class="section" id="castep">
<span id="id2"></span><h2>CASTEP<a class="headerlink" href="#castep" title="Permalink to this headline">¶</a></h2>
<span class="target" id="module-quippy.castep"></span><p>Module contents for <a class="reference internal" href="#module-quippy.castep" title="quippy.castep: CASTEP file readers and writers"><code class="xref py py-mod docutils literal notranslate"><span class="pre">quippy.castep</span></code></a>:</p>
<p class="rubric">Classes</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#quippy.castep.CastepCell" title="quippy.castep.CastepCell"><code class="xref py py-obj docutils literal notranslate"><span class="pre">CastepCell</span></code></a>([cellfile,&nbsp;xml,&nbsp;atoms])</td>
<td>Class to wrap a CASTEP cell (.cell) file</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.castep.CastepParam" title="quippy.castep.CastepParam"><code class="xref py py-obj docutils literal notranslate"><span class="pre">CastepParam</span></code></a>([paramfile,&nbsp;xml,&nbsp;atoms])</td>
<td>Class to wrap a CASTEP parameter (.param) file</td>
</tr>
</tbody>
</table>
<p class="rubric">Functions</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#quippy.castep.check_pspots" title="quippy.castep.check_pspots"><code class="xref py py-obj docutils literal notranslate"><span class="pre">check_pspots</span></code></a>(cluster,&nbsp;cell,&nbsp;param,&nbsp;orig_dir)</td>
<td>Check pseudopotential files are present, and that we have one for each element present in cluster.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.castep.run_castep" title="quippy.castep.run_castep"><code class="xref py py-obj docutils literal notranslate"><span class="pre">run_castep</span></code></a>(cell,&nbsp;param,&nbsp;stem,&nbsp;castep[,&nbsp;…])</td>
<td>Invoke castep and return True if it completed successfully</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#quippy.castep.read_formatted_potential" title="quippy.castep.read_formatted_potential"><code class="xref py py-obj docutils literal notranslate"><span class="pre">read_formatted_potential</span></code></a>(filename)</td>
<td>Load a potential write by CASTEP pot_write_formatted() routine, and convert to a 3-dimensional FortranArray suitable for writing to a .cube file.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.castep.read_formatted_density" title="quippy.castep.read_formatted_density"><code class="xref py py-obj docutils literal notranslate"><span class="pre">read_formatted_density</span></code></a>(filename)</td>
<td>Load a potential write by CASTEP pot_write_formatted() routine, and convert to a 3-dimensional FortranArray suitable for writing to a .cube file.</td>
</tr>
</tbody>
</table>
<dl class="class">
<dt id="quippy.castep.CastepCell">
<em class="property">class </em><code class="descclassname">quippy.castep.</code><code class="descname">CastepCell</code><span class="sig-paren">(</span><em>cellfile=None</em>, <em>xml=None</em>, <em>atoms=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/castep.html#CastepCell"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.castep.CastepCell" title="Permalink to this definition">¶</a></dt>
<dd><p>Class to wrap a CASTEP cell (.cell) file</p>
<p class="rubric">Methods</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#quippy.castep.CastepCell.read" title="quippy.castep.CastepCell.read"><code class="xref py py-obj docutils literal notranslate"><span class="pre">read</span></code></a>(cellfile)</td>
<td>Read a CASTEP .cell file.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.castep.CastepCell.write" title="quippy.castep.CastepCell.write"><code class="xref py py-obj docutils literal notranslate"><span class="pre">write</span></code></a>([cellfile])</td>
<td>Write CASTEP .cell file.</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="quippy.castep.CastepCell.copy">
<code class="descname">copy</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; a shallow copy of D<a class="reference internal" href="_modules/quippy/castep.html#CastepCell.copy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.castep.CastepCell.copy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="quippy.castep.CastepCell.read">
<code class="descname">read</code><span class="sig-paren">(</span><em>cellfile</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/castep.html#CastepCell.read"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.castep.CastepCell.read" title="Permalink to this definition">¶</a></dt>
<dd><p>Read a CASTEP .cell file. cellfile can be a mapping type, filename or an open file</p>
</dd></dl>

<dl class="method">
<dt id="quippy.castep.CastepCell.write">
<code class="descname">write</code><span class="sig-paren">(</span><em>cellfile=&lt;open file '&lt;stdout&gt;'</em>, <em>mode 'w'&gt;</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/castep.html#CastepCell.write"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.castep.CastepCell.write" title="Permalink to this definition">¶</a></dt>
<dd><p>Write CASTEP .cell file. cellfile can be a filename or an open file</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="quippy.castep.CastepParam">
<em class="property">class </em><code class="descclassname">quippy.castep.</code><code class="descname">CastepParam</code><span class="sig-paren">(</span><em>paramfile=None</em>, <em>xml=None</em>, <em>atoms=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/castep.html#CastepParam"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.castep.CastepParam" title="Permalink to this definition">¶</a></dt>
<dd><p>Class to wrap a CASTEP parameter (.param) file</p>
<p class="rubric">Methods</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#quippy.castep.CastepParam.read" title="quippy.castep.CastepParam.read"><code class="xref py py-obj docutils literal notranslate"><span class="pre">read</span></code></a>(paramfile)</td>
<td>Read a CASTEP .param file.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.castep.CastepParam.read_from_castep_output" title="quippy.castep.CastepParam.read_from_castep_output"><code class="xref py py-obj docutils literal notranslate"><span class="pre">read_from_castep_output</span></code></a>(castep_output)</td>
<td>Read user parameters from .castep output.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#quippy.castep.CastepParam.write" title="quippy.castep.CastepParam.write"><code class="xref py py-obj docutils literal notranslate"><span class="pre">write</span></code></a>([paramfile])</td>
<td>Write CASTEP .param file</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="quippy.castep.CastepParam.copy">
<code class="descname">copy</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; a shallow copy of D<a class="reference internal" href="_modules/quippy/castep.html#CastepParam.copy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.castep.CastepParam.copy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="quippy.castep.CastepParam.read">
<code class="descname">read</code><span class="sig-paren">(</span><em>paramfile</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/castep.html#CastepParam.read"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.castep.CastepParam.read" title="Permalink to this definition">¶</a></dt>
<dd><p>Read a CASTEP .param file. paramfile can be a filename or an open file</p>
</dd></dl>

<dl class="method">
<dt id="quippy.castep.CastepParam.read_from_castep_output">
<code class="descname">read_from_castep_output</code><span class="sig-paren">(</span><em>castep_output</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/castep.html#CastepParam.read_from_castep_output"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.castep.CastepParam.read_from_castep_output" title="Permalink to this definition">¶</a></dt>
<dd><p>Read user parameters from .castep output. Input should be filename, file-like object or list of lines</p>
</dd></dl>

<dl class="method">
<dt id="quippy.castep.CastepParam.write">
<code class="descname">write</code><span class="sig-paren">(</span><em>paramfile=&lt;open file '&lt;stdout&gt;'</em>, <em>mode 'w'&gt;</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/castep.html#CastepParam.write"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.castep.CastepParam.write" title="Permalink to this definition">¶</a></dt>
<dd><p>Write CASTEP .param file</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="quippy.castep.CastepPotential">
<em class="property">class </em><code class="descclassname">quippy.castep.</code><code class="descname">CastepPotential</code><span class="sig-paren">(</span><em>cell=None</em>, <em>param=None</em>, <em>castep_exec='castep %s'</em>, <em>stem='castep_callback'</em>, <em>test_mode=False</em>, <em>little_clusters=False</em>, <em>copy_in_files=None</em>, <em>subdir=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/castep.html#CastepPotential"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.castep.CastepPotential" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="function">
<dt id="quippy.castep.check_pspots">
<code class="descclassname">quippy.castep.</code><code class="descname">check_pspots</code><span class="sig-paren">(</span><em>cluster</em>, <em>cell</em>, <em>param</em>, <em>orig_dir</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/castep.html#check_pspots"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.castep.check_pspots" title="Permalink to this definition">¶</a></dt>
<dd><p>Check pseudopotential files are present, and that we have one for
each element present in cluster. Also tries to check spin polarisation
of system matches that specified in parameters.</p>
</dd></dl>

<dl class="function">
<dt id="quippy.castep.run_castep">
<code class="descclassname">quippy.castep.</code><code class="descname">run_castep</code><span class="sig-paren">(</span><em>cell</em>, <em>param</em>, <em>stem</em>, <em>castep</em>, <em>castep_log=None</em>, <em>save_all_check_files=False</em>, <em>save_all_input_files=False</em>, <em>test_mode=False</em>, <em>copy_in_files=None</em>, <em>subdir=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/castep.html#run_castep"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.castep.run_castep" title="Permalink to this definition">¶</a></dt>
<dd><p>Invoke castep and return True if it completed successfully</p>
</dd></dl>

<dl class="function">
<dt id="quippy.castep.read_formatted_potential">
<code class="descclassname">quippy.castep.</code><code class="descname">read_formatted_potential</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/castep.html#read_formatted_potential"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.castep.read_formatted_potential" title="Permalink to this definition">¶</a></dt>
<dd><p>Load a potential write by CASTEP pot_write_formatted() routine, and convert
to a 3-dimensional FortranArray suitable for writing to a .cube file.</p>
</dd></dl>

<dl class="function">
<dt id="quippy.castep.read_formatted_density">
<code class="descclassname">quippy.castep.</code><code class="descname">read_formatted_density</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/castep.html#read_formatted_density"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.castep.read_formatted_density" title="Permalink to this definition">¶</a></dt>
<dd><p>Load a potential write by CASTEP pot_write_formatted() routine, and convert
to a 3-dimensional FortranArray suitable for writing to a .cube file.</p>
</dd></dl>

</div>
<div class="section" id="module-quippy.cube">
<span id="gaussian-cube"></span><span id="cube"></span><h2>Gaussian CUBE<a class="headerlink" href="#module-quippy.cube" title="Permalink to this headline">¶</a></h2>
<p>Module contents for <a class="reference internal" href="#module-quippy.cube" title="quippy.cube: Gaussian CUBE I/O"><code class="xref py py-mod docutils literal notranslate"><span class="pre">quippy.cube</span></code></a>:
..</p>
<blockquote>
<div>!! processed by numpydoc !!</div></blockquote>
</div>
<div class="section" id="module-quippy.dan">
<span id="dan-visualisation-code"></span><span id="dan"></span><h2>DAN visualisation code<a class="headerlink" href="#module-quippy.dan" title="Permalink to this headline">¶</a></h2>
<p>Module contents for <a class="reference internal" href="#module-quippy.dan" title="quippy.dan: DAN visualisation code writer"><code class="xref py py-mod docutils literal notranslate"><span class="pre">quippy.dan</span></code></a>:
..</p>
<blockquote>
<div>!! processed by numpydoc !!</div></blockquote>
</div>
<div class="section" id="module-quippy.imd">
<span id="imd-checkpoint"></span><span id="imd"></span><h2>IMD checkpoint<a class="headerlink" href="#module-quippy.imd" title="Permalink to this headline">¶</a></h2>
<p>Module contents for <a class="reference internal" href="#module-quippy.imd" title="quippy.imd: IMD checkpoint reader"><code class="xref py py-mod docutils literal notranslate"><span class="pre">quippy.imd</span></code></a>:
..</p>
<blockquote>
<div>!! processed by numpydoc !!</div></blockquote>
</div>
<div class="section" id="nmwiz-plugin-for-vmd">
<span id="nmwiz"></span><h2>NMWiz plugin for VMD<a class="headerlink" href="#nmwiz-plugin-for-vmd" title="Permalink to this headline">¶</a></h2>
<p>Supports the <code class="docutils literal notranslate"><span class="pre">.nmd</span></code> format used by <a class="reference external" href="http://prody.csb.pitt.edu/">ProDy</a> and the <a href="#id5"><span class="problematic" id="id6">NMWiz_</span></a> plugin for
<a class="reference external" href="http://www.ks.uiuc.edu/Research/vmd/">VMD</a>.  The files can be read directly into VMD to visualise a molecule’s
normal modes.</p>
<span class="target" id="module-quippy.nmwiz"></span><dl class="class">
<dt id="quippy.nmwiz.NMDWriter">
<em class="property">class </em><code class="descclassname">quippy.nmwiz.</code><code class="descname">NMDWriter</code><a class="reference internal" href="_modules/quippy/nmwiz.html#NMDWriter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.nmwiz.NMDWriter" title="Permalink to this definition">¶</a></dt>
<dd><p>Writer for the <code class="docutils literal notranslate"><span class="pre">.nmd</span></code> format</p>
<p>The Atoms object must have normal modes – both eigenvectors and
eigenvalues (force constants in the normal-mode basis) of the
Hessian matrix – stored in <code class="docutils literal notranslate"><span class="pre">atoms.info['hessian_eigenvalue_X']</span></code>
and <code class="docutils literal notranslate"><span class="pre">atoms.arrays['hessian_eigenvector_X']</span></code>, where <code class="docutils literal notranslate"><span class="pre">X</span></code> ranges
from 1 to the number of stored normal modes.</p>
<p>This writer implements the context manager protocol, so you can
use it like so:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">with</span> <span class="n">NMDWriter</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> <span class="k">as</span> <span class="n">writer</span><span class="p">:</span>
    <span class="n">writer</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">atoms</span><span class="p">)</span>
</pre></div>
</div>
<p>and the associated file will be closed automatically when done.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">.nmd</span></code> file format only supports single configurations, so
this writer doesn’t accept trajectories.</p>
<dl class="method">
<dt id="quippy.nmwiz.NMDWriter.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/nmwiz.html#NMDWriter.__init__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.nmwiz.NMDWriter.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Open <code class="docutils literal notranslate"><span class="pre">filename</span></code> for writing (use <code class="docutils literal notranslate"><span class="pre">-</span></code> for stdout)</p>
</dd></dl>

<dl class="method">
<dt id="quippy.nmwiz.NMDWriter.write">
<code class="descname">write</code><span class="sig-paren">(</span><em>atoms</em>, <em>title=u'quippy atoms'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/nmwiz.html#NMDWriter.write"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.nmwiz.NMDWriter.write" title="Permalink to this definition">¶</a></dt>
<dd><p>Write out the atoms and modes with an optional title</p>
</dd></dl>

<dl class="method">
<dt id="quippy.nmwiz.NMDWriter.close">
<code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/nmwiz.html#NMDWriter.close"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.nmwiz.NMDWriter.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Close the file (unnecessary if using the <code class="docutils literal notranslate"><span class="pre">with</span></code> statment)</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="module-quippy.povray">
<span id="pov-ray"></span><span id="povray"></span><h2>POV-ray<a class="headerlink" href="#module-quippy.povray" title="Permalink to this headline">¶</a></h2>
<p>Module contents for <a class="reference internal" href="#module-quippy.povray" title="quippy.povray: POV-ray script writer"><code class="xref py py-mod docutils literal notranslate"><span class="pre">quippy.povray</span></code></a>:
..</p>
<blockquote>
<div>!! processed by numpydoc !!</div></blockquote>
</div>
<div class="section" id="vasp">
<span id="id4"></span><h2>VASP<a class="headerlink" href="#vasp" title="Permalink to this headline">¶</a></h2>
<span class="target" id="module-quippy.vasp"></span><p>Module contents for <a class="reference internal" href="#module-quippy.vasp" title="quippy.vasp: VASP POSCAR and OUTCAR readers and writers"><code class="xref py py-mod docutils literal notranslate"><span class="pre">quippy.vasp</span></code></a>:</p>
<p class="rubric">Classes</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">Atoms</span></code>([symbols,&nbsp;positions,&nbsp;numbers,&nbsp;tags,&nbsp;…)</td>
<td>Representation of an atomic configuration and its associated properties</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.vasp.VASPWriter" title="quippy.vasp.VASPWriter"><code class="xref py py-obj docutils literal notranslate"><span class="pre">VASPWriter</span></code></a>(out[,&nbsp;species_list])</td>
<td>Writer for VASP POSCAR format</td>
</tr>
</tbody>
</table>
<p class="rubric">Functions</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">ASEReader</span></code>(source[,&nbsp;format])</td>
<td>Helper routine to load from ASE trajectories</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.vasp.VASP_POSCAR_Reader" title="quippy.vasp.VASP_POSCAR_Reader"><code class="xref py py-obj docutils literal notranslate"><span class="pre">VASP_POSCAR_Reader</span></code></a>(outcar[,&nbsp;species,&nbsp;format])</td>
<td>Read a configuration from a VASP OUTCAR file.</td>
</tr>
<tr class="row-odd"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">atoms_reader</span></code>(source)</td>
<td>Decorator to mark a function as a reader for a particular file extension</td>
</tr>
<tr class="row-even"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">frange</span></code>(min[,&nbsp;max,&nbsp;step])</td>
<td>Fortran equivalent of <a class="reference external" href="https://docs.python.org/2.7/library/functions.html#range" title="(in Python v2.7)"><code class="xref py py-func docutils literal notranslate"><span class="pre">range()</span></code></a> builtin.</td>
</tr>
<tr class="row-odd"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">fzeros</span></code>(shape[,&nbsp;dtype])</td>
<td>Create an empty <code class="xref py py-class docutils literal notranslate"><span class="pre">FortranArray</span></code> with Fortran ordering.</td>
</tr>
</tbody>
</table>
<p class="rubric">Attributes</p>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Name</th>
<th class="head">Value</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="xref py py-attr docutils literal notranslate"><span class="pre">AtomsReaders</span></code></td>
<td>—</td>
</tr>
<tr class="row-odd"><td><code class="xref py py-attr docutils literal notranslate"><span class="pre">AtomsWriters</span></code></td>
<td>—</td>
</tr>
<tr class="row-even"><td><code class="xref py py-attr docutils literal notranslate"><span class="pre">ase</span></code></td>
<td>—</td>
</tr>
<tr class="row-odd"><td><code class="xref py py-attr docutils literal notranslate"><span class="pre">np</span></code></td>
<td>—</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="index.html#module-quippy" title="quippy"><code class="xref py py-attr docutils literal notranslate"><span class="pre">quippy</span></code></a></td>
<td>—</td>
</tr>
<tr class="row-odd"><td><code class="xref py py-attr docutils literal notranslate"><span class="pre">re</span></code></td>
<td>&lt;module ‘re’ from ‘/home/travis/virtualenv/python2.7.14/lib/python2.7/re.pyc’&gt;</td>
</tr>
<tr class="row-even"><td><code class="xref py py-attr docutils literal notranslate"><span class="pre">sys</span></code></td>
<td>&lt;module ‘sys’ (built-in)&gt;</td>
</tr>
</tbody>
</table>
<dl class="class">
<dt id="quippy.vasp.VASPWriter">
<em class="property">class </em><code class="descclassname">quippy.vasp.</code><code class="descname">VASPWriter</code><span class="sig-paren">(</span><em>out</em>, <em>species_list=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/vasp.html#VASPWriter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.vasp.VASPWriter" title="Permalink to this definition">¶</a></dt>
<dd><p>Writer for VASP POSCAR format</p>
</dd></dl>

<dl class="function">
<dt id="quippy.vasp.VASP_POSCAR_Reader">
<code class="descclassname">quippy.vasp.</code><code class="descname">VASP_POSCAR_Reader</code><span class="sig-paren">(</span><em>outcar</em>, <em>species=None</em>, <em>format=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/vasp.html#VASP_POSCAR_Reader"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.vasp.VASP_POSCAR_Reader" title="Permalink to this definition">¶</a></dt>
<dd><p>Read a configuration from a VASP OUTCAR file.</p>
</dd></dl>

</div>
<div class="section" id="ase-supported-files-types">
<h2>ASE supported files types<a class="headerlink" href="#ase-supported-files-types" title="Permalink to this headline">¶</a></h2>
<p>Since <a class="reference internal" href="atoms.html#quippy.atoms.Atoms" title="quippy.atoms.Atoms"><code class="xref py py-class docutils literal notranslate"><span class="pre">quippy.atoms.Atoms</span></code></a> is a subclass of the ASE
<code class="xref py py-class docutils literal notranslate"><span class="pre">ase.atoms.Atoms</span></code> class, all of the ASE I/O formats can also be
used with quippy: see <a class="reference external" href="https://wiki.fysik.dtu.dk/ase/ase/io/io.html#ase.io.read" title="(in ASE)"><code class="xref py py-func docutils literal notranslate"><span class="pre">ase.io.read()</span></code></a> for a list of supported
formats. To convert from <code class="xref py py-class docutils literal notranslate"><span class="pre">ase.atoms.Atoms</span></code> to
<code class="xref py py-class docutils literal notranslate"><span class="pre">quippy.atoms,Atoms</span></code>, simply pass the ASE Atoms object to the
quippy Atoms constructor, e.g.:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">quippy.atoms</span> <span class="k">import</span> <span class="n">Atoms</span> <span class="k">as</span> <span class="n">QuippyAtoms</span>
<span class="kn">from</span> <span class="nn">ase.atoms</span> <span class="k">import</span> <span class="n">Atoms</span> <span class="k">as</span> <span class="n">ASEAtoms</span>
<span class="kn">from</span> <span class="nn">ase.io</span> <span class="k">import</span> <span class="n">read</span>

<span class="n">ase_atoms</span> <span class="o">=</span> <span class="n">read</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
<span class="n">quippy_atoms</span> <span class="o">=</span> <span class="n">QuippyAtoms</span><span class="p">(</span><span class="n">ase_atoms</span><span class="p">)</span>
</pre></div>
</div>
<p>Similarily, to use one of the quippy file formats with other ASE
tools:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">quippy.io</span> <span class="k">import</span> <span class="n">read</span>
<span class="n">quippy_atoms</span> <span class="o">=</span> <span class="n">read</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
<span class="n">ase_atoms</span> <span class="o">=</span> <span class="n">ASEAtoms</span><span class="p">(</span><span class="n">quippy_atoms</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="adding-a-new-file-type">
<h2>Adding a new file type<a class="headerlink" href="#adding-a-new-file-type" title="Permalink to this headline">¶</a></h2>
<p>To add support for a new file format, implement routines which
read from or write to files following the templates below.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">sample_reader</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span>
    <span class="c1"># insert code to open `filename` for reading</span>

    <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
       <span class="c1"># determine if more frame are available</span>
       <span class="k">if</span> <span class="n">more_frames</span><span class="p">:</span>
          <span class="c1"># read next frame from `filename` into new Atoms object</span>
          <span class="n">at</span> <span class="o">=</span> <span class="n">Atoms</span><span class="p">()</span>
          <span class="k">yield</span> <span class="n">at</span>
       <span class="k">else</span><span class="p">:</span>
          <span class="k">break</span>


<span class="k">class</span> <span class="nc">sample_writer</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">):</span>
       <span class="c1"># insert code to open `filename` for writing</span>
       <span class="k">pass</span>

    <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">at</span><span class="p">):</span>
       <span class="c1"># insert code to write `at` to `filename`</span>
       <span class="k">pass</span>

    <span class="k">def</span> <span class="nf">close</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
       <span class="c1"># insert code to close `filename`</span>
       <span class="k">pass</span>
</pre></div>
</div>
<p><code class="xref py py-func docutils literal notranslate"><span class="pre">sample_reader()</span></code> is a generator which yields a succession of
<a class="reference internal" href="atoms.html#quippy.atoms.Atoms" title="quippy.atoms.Atoms"><code class="xref py py-class docutils literal notranslate"><span class="pre">Atoms</span></code></a> objects, raising <code class="xref py py-exc docutils literal notranslate"><span class="pre">StopIteration</span></code> when there are no
more available - for a file format which only permits one
configuration per file, a simplified implementation template would be:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">sample_reader</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span>
   <span class="c1"># insert code to open `filename` for reading</span>
   <span class="c1"># insert code to read from `filename` into new Atoms object</span>
   <span class="k">yield</span> <span class="n">at</span>
</pre></div>
</div>
<p>To register the new file format, you just need to set entries in
<code class="xref py py-attr docutils literal notranslate"><span class="pre">AtomsReaders</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">AtomsWriters</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">quippy</span> <span class="k">import</span> <span class="n">AtomsReaders</span><span class="p">,</span> <span class="n">AtomsWriters</span>
<span class="n">AtomsReaders</span><span class="p">[</span><span class="s1">&#39;new_format&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">sample_reader</span>
<span class="n">AtomsWriters</span><span class="p">[</span><span class="s1">&#39;new_format&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">sameple_writer</span>
</pre></div>
</div>
<p>For the case of reading, there is a generator <code class="xref py py-func docutils literal notranslate"><span class="pre">atoms_reader()</span></code>
which can be used to simplify the registration process:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@atoms_reader</span><span class="p">(</span><span class="s1">&#39;new_format&#39;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">sample_reader</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span>
   <span class="o">...</span>
</pre></div>
</div>
<p>See the code in <code class="xref py py-mod docutils literal notranslate"><span class="pre">quippy.xyz</span></code> <a class="reference internal" href="#module-quippy.netcdf" title="quippy.netcdf: Python reference implementation of NetCDF I/O"><code class="xref py py-mod docutils literal notranslate"><span class="pre">quippy.netcdf</span></code></a> and
<a class="reference internal" href="#module-quippy.castep" title="quippy.castep: CASTEP file readers and writers"><code class="xref py py-mod docutils literal notranslate"><span class="pre">quippy.castep</span></code></a> for full examples.</p>
</div>
</div>


           </div>
           
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2008-2016, James Kermode

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>